package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.YxDeviceExtraInfo;
import com.ruoyi.system.service.IYxDeviceExtraInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设备拓展信息Controller
 * 
 * @author lingyu
 * @date 2024-03-14
 */
@RestController
@RequestMapping("/system/deviceExtraInfo")
public class YxDeviceExtraInfoController extends BaseController
{
    @Autowired
    private IYxDeviceExtraInfoService yxDeviceExtraInfoService;

    /**
     * 查询设备拓展信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:deviceExtraInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(YxDeviceExtraInfo yxDeviceExtraInfo)
    {
        startPage();
        List<YxDeviceExtraInfo> list = yxDeviceExtraInfoService.selectYxDeviceExtraInfoList(yxDeviceExtraInfo);
        return getDataTable(list);
    }

    /**
     * 导出设备拓展信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:deviceExtraInfo:export')")
    @Log(title = "设备拓展信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YxDeviceExtraInfo yxDeviceExtraInfo)
    {
        List<YxDeviceExtraInfo> list = yxDeviceExtraInfoService.selectYxDeviceExtraInfoList(yxDeviceExtraInfo);
        ExcelUtil<YxDeviceExtraInfo> util = new ExcelUtil<YxDeviceExtraInfo>(YxDeviceExtraInfo.class);
        util.exportExcel(response, list, "设备拓展信息数据");
    }

    /**
     * 获取设备拓展信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:deviceExtraInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(yxDeviceExtraInfoService.selectYxDeviceExtraInfoById(id));
    }

    /**
     * 新增设备拓展信息
     */
    @PreAuthorize("@ss.hasPermi('system:deviceExtraInfo:add')")
    @Log(title = "设备拓展信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YxDeviceExtraInfo yxDeviceExtraInfo)
    {
        return toAjax(yxDeviceExtraInfoService.insertYxDeviceExtraInfo(yxDeviceExtraInfo));
    }

    /**
     * 修改设备拓展信息
     */
    @PreAuthorize("@ss.hasPermi('system:deviceExtraInfo:edit')")
    @Log(title = "设备拓展信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YxDeviceExtraInfo yxDeviceExtraInfo)
    {
        return toAjax(yxDeviceExtraInfoService.updateYxDeviceExtraInfo(yxDeviceExtraInfo));
    }

    /**
     * 删除设备拓展信息
     */
    @PreAuthorize("@ss.hasPermi('system:deviceExtraInfo:remove')")
    @Log(title = "设备拓展信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yxDeviceExtraInfoService.deleteYxDeviceExtraInfoByIds(ids));
    }
}
